<template>
  <div>
    <!-- 需求计划汇总查询N+1 -->
    <TopFilter
      :list="topFilterList"
      :cols="3"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
      :labelWidth="110"
    ></TopFilter>

    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => this.columns = columns"
    >
      <template slot="controls" slot-scope="props">
      </template>
    </FilterTable>

    <BaseDialog
      :visible.sync="issearch"
      :title="'基本信息'"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <ownerSeacher  :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>

  </div>
</template>
<script>
import ownerSeacher from './ownerSeacher';
export default {
  name:'TemplateDistribution',
  data(){
    this.BaseTable=null;
    return{
      topFilterList:this.createdFrom(),
      columns:this.createdTable(),
      fetchParams:{

      },
      fetchApi:()=>{},
      formData:{},
      visible:false,
      issearch:false,
      isiue:false,
    }
  },
  components: {
    ownerSeacher,
  },
  mounted(){
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created(){

  },
  methods:{
    createdFrom(){
      return [
        {
          type: 'SELECT',
          label: '办事处',
          fieldName: 'syb',
          placeholder: '请选择',
          itemList:[]
        },

        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'jxsdm1',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'jxsmc',
          placeholder: '请选择',
        },
        {
          type: 'SELECT',
          label: '车系名称',
          fieldName: 'cxmc',
          placeholder: '请选择',
          itemList:[]
        },
        {
          type: 'SELECT',
          label: '车型名称',
          fieldName: 'cxmc',
          placeholder: '请选择',
          itemList:[]
        },


        {
          type: 'DATE',
          label: '月份',
          fieldName: 'yf',
          placeholder: '请选择',
          dateType:'month'
        },

      ]
    },
    createdTable(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        {
          title: '状态',
          dataIndex: 'status',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],

        },
        {
          title: '事业部',
          dataIndex: 'syb',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],

        },
        {
          title: '办事处',
          dataIndex: 'bsc',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],
        },
        {
          title: '经销商代码',
          dataIndex: 'jxsdm',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商',
          dataIndex: 'jxsmc',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],

        },
        {
          title: '品牌名称',
          dataIndex: 'zcbmms',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车系名称',
          dataIndex: 'zcbm',
          sorter: true,
          filter: true,
          filterType: 'input'
        },

        {
          title: '车型名称',
          dataIndex: 'cxmc2',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '月份',
          dataIndex: 'yf',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务数量(批售)',
          dataIndex: 'rwslps',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务数量(终端)',
          dataIndex: 'rwslzd',
          sorter: true,
          filter: true,
          filterType: 'input'
        },

        {
          title: '下发日期',
          dataIndex: 'xfrq',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '提交日期',
          dataIndex: 'tjrq',
          sorter: true,
          filter: true,
          filterType: 'input',

        },
        {
          title: '提交人',
          dataIndex: 'tjr',
          sorter: true,
          filter: true,
          filterType: 'input',

        },

      ]
    },
    selectChangeHandle(row){

    },
    seacherFun(){
      this.issearch=true;
    },
    addHandle(data){
      this.isiue=true
    },
    changeHandle(params){
      this.fetchParams=Object.assign({},this.fetchParams,params)
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },
    editHandle(data){
      this.visible=true
    },
    emitcloseHandler(){
      this.visible=false
      this.fetchParams=Object.assign({},this.fetchParams,params)
    }
  }
}
</script>
